import request from './http'
import { LocationQueryValue } from 'vue-router'

interface UserLogin {
  email: string,
  password: string | number
}
export const userLogin = (options: UserLogin) => request({ method: 'post', url: 'api/user/login', data: options })

// /api/user/current
export const userCurrent = ()=>request.get('/api/user/current')
//用户信息
export const getuserlist = () => {
  return request({
    url: 'api/columns?currentPage=1&pageSize=5',
    method: 'get',
  })
}
// interface SpecialConfig {
//   page: number,
//   pageSize: number,

// }
// export const getSpecialList = (options: SpecialConfig) => {
//   return request({
//     method: 'get',
//     url: `api/columns/?/posts?currentPage=${options.page}&pageSize=${options.pageSize}`,
//   })
// }
//首页文章列表
interface ListConfig {
  currentPage: number,
  pageSize: number
}
export const getColumnList = (options: ListConfig) => request({ method: 'get', url: 'api/columns', params: options })



// 专栏详情
interface getcolum {
    page: number,
    pageSize: number,
    id: LocationQueryValue | LocationQueryValue[];
  }
  export const getcolum = (options: getcolum) => request({ method: 'get', url: `api/columns/${options.id}/posts?currentPage=${options.page}&pageSize=${options.pageSize}`})



//删除收藏
export const userDelCollect = (id: string) => {
  return request({
    url: `api/posts/${id}`,
    method: 'DELETE',
  })
}

//图片上传
export const uploadFile = (options: any) => {
  console.log(options);
  return request({
    method: 'post',
    url: 'api/upload',
    data: options
  })
}
//填加内容-http://api.vikingship.xyz/api/posts
interface AddarticleConfig {
  title: string,
  content: string,
  image?: string,//可有可无
  author: string,
  column: string
}
export const addArticle = (options: AddarticleConfig) => request({ method: 'post', url: 'api/posts', data: options })







